<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0"/>
    <title>登陆</title>
    <script type="text/javascript" src="{{ asset('home/js/responsive.js')}}"></script>
    <script type="text/javascript" src="{{asset('/home/js/jquery-3.1.0.js')}}"></script>
    <script type="text/javascript" src="{{asset('/home/js/jquery.slides.js')}}"></script>
    <script type="text/javascript" src="{{asset('/home/js/my_slides.js')}}"></script>
    <link rel="stylesheet" href="{{ asset('/home/css/base.css')}}"/>
    <link rel="stylesheet" href="{{ asset('/home/css/index.css')}}?version=3"/>
</head>
<body>
    <div class="yc_layout">
        <h3 class="title">SCAM首页</h3>
        <!-- 轮播图 -->
        <div class="yc_banner">
            <div class="slides" id="slides">
                @foreach($data['grids'] as $k => $v)
                <a href="{{$v->url}}"><img src="{{asset($v->img)}}"></a>
                @endforeach
            </div>
        </div>
        {{--<div class="new">--}}
            {{--<div class="left">--}}
                {{--<a href="{{ url('newcomer') }}">--}}
                    {{--<img src="{{asset('/home/images/p1.png')}}" alt="">--}}
                    {{--<div class="banner">--}}
                        {{--<h4>新手赚钱宝典</h4>--}}
                        {{--<p>新手必知的知识点</p>--}}
                    {{--</div>--}}
                {{--</a>--}}
            {{--</div>--}}
            {{--<div class="left">--}}
                {{--<a href="{{ url('alllist') }}">--}}
                    {{--<img src="{{asset('/home/images/p1.png')}}" alt="">--}}
                    {{--<div class="banner">--}}
                        {{--<h4>赚钱英雄榜</h4>--}}
                        {{--<p>新手必知的知识点</p>--}}
                    {{--</div>--}}
                {{--</a>--}}
            {{--</div>--}}
        {{--</div>--}}

        <!-- 主体 -->
        <div class="yc_content">
            @if(in_array($data['status'],[1,2]))
            <div class="plate">
                <h3>新手专区</h3>
                <table>
                    @foreach($data['new'] as $k => $v)
                    <tr link="{{ url('content').'/'.$v->id }}">
                        <td>{{$v->name}}</td>
                        <td>{{$v->count}}份</td>
                        <td>{{sprintf('%.2f',($v->price/100)) }}元</td>
                    </tr>
                    @endforeach
                </table>
                @if($data['status'] == 1)
                <div class="join"><a href="{{url('login')}}">立即加入</a></div>
                @endif
            </div>
            @endif
            <div class="plate">
                <h3>挣钱专区<a href="{{ url('slide') }}">幻灯模式</a></h3>
                <table class="earn">
                    @foreach($data['notnew'] as $k => $v)
                        <tr link="{{ url('content').'/'.$v->id }}">
                            <td>{{$v->name}}</td>
                            <td>{{$v->count}}份</td>
                            <td>{{sprintf('%.2f',($v->price/100)) }}元</td>
                        </tr>
                    @endforeach
                </table>
                <div class="join more">加载更多</div>
            </div>
        </div>

        {{--底部--}}
        <div class="footer">
            <div class="left">
                <a href="{{ url('/') }}">
                    <div class="img"></div>
                    {{--<img src="{{asset('/home/images/p1.png')}}" alt="">--}}
                    <span>我要赚钱</span>
                </a>

            </div>
            <div class="left">
                <a href="{{ url('personal') }}">
                    <div class="img"></div>
                    {{--<img src="{{asset('/home/images/p1.png')}}" alt="">--}}
                    <span>会员中心</span>
                </a>
            </div>
        </div>
    </div>

    <script>
        $(document).on('click','table tr',function () {
            location.href = $(this).attr("link");
        })

//        var height = $(window).height() - $('.title').height() - $('.yc_banner').height() - $('.new').height() - $('.footer').height();
        var height = $(window).height() - $('.title').height() - $('.yc_banner').height()- $('.footer').height();
        console.log(height);
        $('.yc_content').css('height',height);
        var page = 1;
        var pagesize = 10;
        $('.more').click(function () {

            $.ajax({
                url:"{{ url('more') }}",
                data:{page:page,pagesize:pagesize},
                type:'get',
                success:function (data) {
                    var length = data.data.length;
                    var str = '';
                    if(data.code == 0){
                        if(length == 0){
                            $('.more').hide();
                        }else{
                            page++;
                            for(var i=0;i<length;i++){
                                str += `<tr link="{{ url('content/${data.data[i].id}')}}">
                                        <td>${data.data[i].name}</td>
                                        <td>${data.data[i].count}份</td>
                                        <td>${data.data[i].price}元</td>
                                    </tr>`;
                            }
                            $('.earn').append(str);
                        }

                    }
                },
                error:function () {
                    console.log('no');
                },
                dataType:'json'
            })
        })
    </script>
</body>
</html>